﻿// Decompiled with JetBrains decompiler
// Type: MCM.Abstractions.CollectionExtensions
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using Bannerlord.ModuleManager;
using MCM.Common;
using System;
using System.Collections.Generic;
using System.Linq;

#nullable enable
namespace MCM.Abstractions
{
  internal static class CollectionExtensions
  {
    public static IOrderedEnumerable<SettingsPropertyGroupDefinition> SortDefault(
      this IEnumerable<SettingsPropertyGroupDefinition> enumerable)
    {
      return enumerable.OrderByDescending<SettingsPropertyGroupDefinition, bool>((Func<SettingsPropertyGroupDefinition, bool>) (x => x.GroupName == SettingsPropertyGroupDefinition.DefaultGroupName)).ThenByDescending<SettingsPropertyGroupDefinition, int>((Func<SettingsPropertyGroupDefinition, int>) (x => x.Order)).ThenByDescending<SettingsPropertyGroupDefinition, string>((Func<SettingsPropertyGroupDefinition, string>) (x => LocalizationUtils.Localize(x.GroupName)), (IComparer<string>) new AlphanumComparatorFast());
    }

    public static IOrderedEnumerable<ISettingsPropertyDefinition> SortDefault(
      this IEnumerable<ISettingsPropertyDefinition> enumerable)
    {
      return enumerable.OrderBy<ISettingsPropertyDefinition, int>((Func<ISettingsPropertyDefinition, int>) (x => x.Order)).ThenBy<ISettingsPropertyDefinition, string>((Func<ISettingsPropertyDefinition, string>) (x => LocalizationUtils.Localize(x.DisplayName)), (IComparer<string>) new AlphanumComparatorFast());
    }

    public static SettingsPropertyGroupDefinition? GetGroupFromName(
      this IEnumerable<SettingsPropertyGroupDefinition> groupsList,
      string groupName)
    {
      return groupsList.FirstOrDefault<SettingsPropertyGroupDefinition>((Func<SettingsPropertyGroupDefinition, bool>) (x => x.GroupNameRaw == groupName));
    }
  }
}
